/**
 * Created by zhangxiaoyu on 16/4/28.
 */
angular.module('hyt.menuService',[])

//获取菜单列表数据
.factory('MenuListFactory',function($resource, $rootScope,ENV,Storage){
    var APIUrl =  Storage.get('fwqdz'),
        menuListData = {},result,resultApk;

    var resource = $resource(APIUrl);

    return {
        getMenuList: function(sid,user_id,yh_id,sfwlgs,dw_id) {
            return resource.save({
                'ACTION_NAME': 'loginBiz.menu',
                'SID':sid,
                'USER_ID':user_id,
                'ACTION_INFO': {
                    'yh_id':yh_id,
                    'sfwlgs':sfwlgs,
                    'dw_id':dw_id
                }
            }, function(r) {
                menuListData= r.ACTION_INFO;
                console.log(menuListData);
                $rootScope.$broadcast('MenuList.menuUpdated');
            });
        },
        getMenu : function(){
            return menuListData;
        },
        queryContent1:function(sid,user_id,yh_id,dw_id){
            return resource.save({
                SID:sid,
                USER_ID:user_id,
                ACTION_NAME:'sqlKeyBiz.page#updateContent_query',
                ACTION_INFO:{
                    'app_type':'1',
                    'yh_id':yh_id,
                    'dw_id':dw_id
                }
            },function(resp){
                result=resp;
                console.log(resp);
                $rootScope.$broadcast('UpdateContent1.APK');
            });
        },
        getResultContent1:function(){
            return result;
        },
        checkApk:function(version_no,sid,user_id,yh_id,dw_id){
            return resource.save({
                SID:sid,
                USER_ID:user_id,
                ACTION_NAME:'sqlKeyBiz.page#version_query',
                ACTION_INFO:{
                    'app_type':'1',
                    'version_no':version_no,
                    'yh_id':yh_id,
                    'dw_id':dw_id
                }
            },function(resp){
                resultApk=resp;
                console.log(resp);
                $rootScope.$broadcast('UpdateApk.APK');
            });
        },
        getResultApk:function(){
            return resultApk;
        }
    };
});
